import Vue from 'vue'
import Router from 'vue-router'
import 'styles/reset.css'
Vue.use(Router)
const commonRoutes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('pages/login/Login')
  },
  {
    path: '/',
    redirect: '/welcome'
  }
]
const createRouter = () => new Router({
  mode: 'history',
  base: '/dfront/',
  routes: commonRoutes
})
// 需要通过后台数据来生成的组件
export const asyncRoutes = {
  'roleManage': {
    path: '/roleManage',
    name: 'roleManage',
    component: () => import('pages/menuItem/roleManage/')
  },
  'menuManage': {
    path: '/menuManage',
    name: 'menuManage',
    component: () => import('pages/menuItem/menuManage/')
  },
  'accountManage': {
    path: '/accountManage',
    name: 'accountManage',
    component: () => import('pages/menuItem/accountManage/')
  },
  'addingGoods': {
    path: '/addingGoods',
    name: 'addingGoods',
    component: () => import('pages/menuItem/adding-goods/')
  },
  'goodsList': {
    path: '/goodsList',
    name: 'goodsList',
    component: () => import('pages/menuItem/goods-list/')
  },
  'codeManagement': {
    path: '/codeManagement',
    name: 'codeManagement',
    component: () => import('pages/menuItem/code-management/')
  },
  'fleeingGoods': {
    path: '/fleeingGoods',
    name: 'fleeingGoods',
    component: () => import('pages/menuItem/fleeing-goods/')
  },
  'menuConfig': {
    path: '/menuConfig',
    name: 'menuConfig',
    component: () => import('pages/menuItem/menuConfig/')
  }
}
const router = createRouter()

export function resetRouter () {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher
}

export default router
